home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / bcfamily / source / huge.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-12  |  1.6 KB  |  75 lines

  1. //
  2. //      *******************************************************************
  3. //        JdeBP C++ Library Routines          General Public Licence v1.00
  4. //            Copyright (c) 1991,1992     Jonathan de Boyne Pollard
  5. //      *******************************************************************
  6. //
  7. // Part of FamAPI.LIB
  8. //
  9.  
  10. #include "famapi.h"
  11. #include "dosdos.h"
  12.  
  13. //
  14. //    Get shift count for huge segments
  15. //
  16. USHORT _APICALL
  17. DosGetHugeShift    ( unsigned short far *PtrShift )
  18. {
  19.     *PtrShift = 0x1000 ;
  20.     return NO_ERROR ;
  21. }
  22.  
  23. //
  24. //    Allocate a huge segment set
  25. //
  26. USHORT _APICALL
  27. DosAllocHuge ( USHORT NumSegs,
  28.                USHORT PartialSeg,
  29.                USHORT far *PtrSelector,
  30.                USHORT MaxNumSegs,
  31.                USHORT AllocFlags )
  32. {
  33.     if (NumSegs > 0xF) return ERROR_NOT_ENOUGH_MEMORY ; // Limit to 1Mb
  34.  
  35.     if (PartialSeg) NumSegs-- ;
  36.  
  37.     // Round up to next paragraph
  38.  
  39.     if (PartialSeg & 0xF)
  40.         _BX = (NumSegs << 12) + (PartialSeg >> 4) + 1 ;
  41.     else
  42.         _BX = (NumSegs << 12) + (PartialSeg >> 4) ;
  43.  
  44.     _AH = 0x48 ;
  45.     Dos3Call() ;
  46.     if (_FLAGS & 0x0001) return _AX;
  47.     *PtrSelector = _AX ;
  48.     return NO_ERROR ;
  49. }
  50.  
  51. //
  52. //    Re-Allocate a huge segment set
  53. //
  54. USHORT _APICALL
  55. DosReallocHuge ( USHORT NumSegs,
  56.                  USHORT PartialSeg,
  57.                  USHORT Selector)
  58. {
  59.     if (NumSegs > 0xF) return ERROR_NOT_ENOUGH_MEMORY ; // Limit to 1Mb
  60.  
  61.     if (PartialSeg) NumSegs-- ;
  62.  
  63.     // Round up to next paragraph
  64.  
  65.     if (PartialSeg & 0xF)
  66.         _BX = (NumSegs << 12) + (PartialSeg >> 4) + 1 ;
  67.     else
  68.         _BX = (NumSegs << 12) + (PartialSeg >> 4) ;
  69.  
  70.     _ES = Selector ;
  71.     _AH = 0x4A ;
  72.     Dos3Call() ;
  73.     return (_FLAGS & 0x0001) ? _AX : NO_ERROR;
  74. }
  75.